﻿using System.Data;

namespace ConfExpert.Forms.SatinAlma.YeniYapi
{
    public partial class TaleplerFoyu : DevExpress.XtraReports.UI.XtraReport
    {
        private DataSet ds;
        string tip = string.Empty;
        public TaleplerFoyu(DataSet dsFoy, string tip)
        {
            this.tip = tip;
            this.ds = dsFoy;
            InitializeComponent();

            BindDstoReport();
        }

        void BindDstoReport()
        {
            DataRow drHeader = ds.Tables[0].Rows[0];

            tcPO.Text = drHeader["FoyId"].ToString();

            tcOlusturan.Text = drHeader["Olusturan"].ToString();
            tcOlusturulmaTarihi.Text = drHeader["OlusturulmaTarihi"].ToString();

            DataTable dtDetail = ds.Tables[1];
            string DetailTableName = dtDetail.TableName;

            this.DataMember = DetailTableName;
            this.DataSource = ds;

            tcProduct.DataBindings.Add("Text", null, DetailTableName + ".Kumas");
            tcUretici.DataBindings.Add("Text", null, DetailTableName + ".Uretici");
            xrPicture.DataBindings.Add("Image", null, DetailTableName + ".Photo");

            switch (tip)
            {
                case "Yıkama":
                    tcYikamaRecetesi.DataBindings.Add("Text", null, DetailTableName+".YikamaRecetesi");
                    tcBaslikYıkamaRecetesi.Text = "Yıkama Reçetesi";
                    tcHeader.Text = "Yıkama Testi Talebi";
                    break;

                case "Ütü":
                    tcYikamaRecetesi.DataBindings.Add("Text", null, DetailTableName + ".Utu");
                    tcBaslikYıkamaRecetesi.Text = "Ütü Reçetesi";
                    tcHeader.Text = "Ütü Testi Talebi";
                    break;
            }
        }
    }
}